﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:Hinshelwood.TFSStickyBuddy;assembly=Hinshelwood.TFSStickyBuddy"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:tfs="clr-namespace:Microsoft.TeamFoundation.WorkItemTracking.Client;assembly=Microsoft.TeamFoundation.WorkItemTracking.Client">
    
    <!-- This is the style for the list of WorkItemsListBoxStyle on the  control -->
    <Style TargetType="{x:Type ListBox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <ScrollViewer HorizontalScrollBarVisibility="Disabled" Margin="0">
                        <WrapPanel IsItemsHost="True" Width="200" MaxHeight="500" VerticalAlignment="Top" />
                    </ScrollViewer>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- This is the style for the photo containers in the list of photos on the ItemInfo control -->
    <Style TargetType="{x:Type ListBoxItem}">
        <Setter Property="Margin" Value="2" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Grid SnapsToDevicePixels="true">
                        <Border x:Name="Border"  BorderBrush="LightGray" BorderThickness="2" CornerRadius="4" Background="{TemplateBinding Background}" />
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!-- Change IsSelected background to set the selection color for the photos -->
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Background" Value="#FFFFFF" TargetName="Border" />
                        </Trigger>
                        <DataTrigger Binding="{Binding Path=Value.State}" Value="Closed">
                            <Setter Property="Background" Value="LightGreen" TargetName="Border" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=Value.State}" Value="Fixed">
                            <Setter Property="Background" Value="Orange" TargetName="Border" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=Value.State}" Value="Active">
                            <Setter Property="Background" Value="Red" TargetName="Border" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=Value.State}" Value="Proposed">
                            <Setter Property="Background" Value="LightBlue" TargetName="Border" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- TODO: Get Value.Fields('WorkItemType').Value from WIItem -->
    <local:WIItemFieldConverter x:Key="WIItemFieldConverter" />

    <DataTemplate DataType="{x:Type local:WIItem}">
        <DockPanel HorizontalAlignment="Center" Margin="3">
            <TextBlock DockPanel.Dock="Top" HorizontalAlignment="Center" FontSize="8" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis">
                <TextBlock.Text>
                    <Binding Path="Value" Converter="{StaticResource WIItemFieldConverter}" ConverterParameter="WorkItemType" />
                </TextBlock.Text>
            </TextBlock>
                <TextBlock DockPanel.Dock="Top" HorizontalAlignment="Center" Text="{Binding Path=Value.Id}" FontSize="16" Margin="0" TextWrapping="WrapWithOverflow" VerticalAlignment="Center" />
                <TextBlock DockPanel.Dock="Top" HorizontalAlignment="Center" FontSize="6" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" MaxWidth="50">
                    <TextBlock.Text>
                        <Binding Path="Value" Converter="{StaticResource WIItemFieldConverter}" ConverterParameter="Assigned To" />
                    </TextBlock.Text>
                </TextBlock>
                <TextBlock Text="{Binding Path=Value.State}" HorizontalAlignment="Center" FontSize="6" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" />
                <DockPanel.ToolTip>
                <ToolTip Style="{DynamicResource WorkItemToolTip}" Content="{Binding Path=Value.Title}" />
            </DockPanel.ToolTip>
        </DockPanel>
    </DataTemplate>

    <!-- ToolTip -->
    <Style x:Key="DiagramToolTip" TargetType="ToolTip">
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="HasDropShadow" Value="True" />
        <Setter Property="Foreground" Value="#FFFFFFFF" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToolTip">
                    <Border Name="Border" Background="{DynamicResource DiagramToolTipBackgroundBrush}" BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="10,10,10,10">
                        <StackPanel>
                            <Border BorderBrush="#02747474" Background="#02000000" HorizontalAlignment="Center" Margin="10,5,10,0" VerticalAlignment="Top" BorderThickness="1,1,1,1" x:Name="AvatarPhotoBorder">
                                <Border.BitmapEffect>
                                    <DropShadowBitmapEffect ShadowDepth="7" Softness="0.75" />
                                </Border.BitmapEffect>
                                <Image x:Name="Avatar" Source="{Binding Path=Item.Avatar, Mode=OneWay}" Stretch="Uniform" VerticalAlignment="Top" MaxWidth="90" MaxHeight="85" HorizontalAlignment="Left" StretchDirection="DownOnly" />
                            </Border>
                            <!--<Border x:Name="NoPhotoBorder" Visibility="{Binding Path=Item.HasAvatar, Converter={StaticResource ComposingConverter}, Mode=Default}" BorderBrush="#FFFFFFFF" Background="#02FFFFFF" Margin="10,5,10,0">
                                <Rectangle Fill="{DynamicResource NoPhotoBrush}" Stroke="{x:Null}" Width="70" Height="85" x:Name="NoPhotoRectangle">
                                    <Rectangle.BitmapEffect>
                                        <DropShadowBitmapEffect ShadowDepth="7" Softness="0.75" />
                                    </Rectangle.BitmapEffect>
                                </Rectangle>
                            </Border>-->
                            <ContentPresenter Margin="10,0,10,3" HorizontalAlignment="Right" TextBlock.TextAlignment="Right" />
                        </StackPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasDropShadow" Value="true">
                            <Setter TargetName="Border" Property="CornerRadius" Value="4" />
                            <Setter TargetName="Border" Property="SnapsToDevicePixels" Value="true" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- WorkItemToolTip -->
    <Style x:Key="WorkItemToolTip" TargetType="ToolTip">
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="HasDropShadow" Value="True" />
        <Setter Property="Foreground" Value="#FFFFFFFF" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToolTip">
                    <Border Name="Border" Background="{DynamicResource DiagramToolTipBackgroundBrush}" BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="10,10,10,10">
                        <StackPanel>
                            <Border BorderBrush="#02747474" Background="#02000000" HorizontalAlignment="Center" Margin="10,5,10,0" VerticalAlignment="Top" BorderThickness="1,1,1,1" x:Name="AvatarPhotoBorder">
                                <Border.BitmapEffect>
                                    <DropShadowBitmapEffect ShadowDepth="7" Softness="0.75" />
                                </Border.BitmapEffect>
                                <StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <Label Content="{Binding Path=Value.Id}" FontSize="16" />
                                        <Label Content="{Binding Path=Value.Title}" FontSize="16" />
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <Label Content="Assigned To: " />
                                        <Label>
                                            <Label.Content>
                                                <Binding Path="Value" Converter="{StaticResource WIItemFieldConverter}" ConverterParameter="Assigned To" />
                                            </Label.Content>
                                        </Label>
                                    </StackPanel>
                                    <Label Content="{Binding Path=Value.Description}" />
                                </StackPanel>
                            </Border>
                            <ContentPresenter Margin="10,0,10,3" HorizontalAlignment="Right" TextBlock.TextAlignment="Right" />
                        </StackPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasDropShadow" Value="true">
                            <Setter TargetName="Border" Property="CornerRadius" Value="4" />
                            <Setter TargetName="Border" Property="SnapsToDevicePixels" Value="true" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Project node ProjectNodeTemplate -->
    <ControlTemplate x:Key="ProjectNodeTemplate" TargetType="{x:Type local:DiagramNode}">
        <StackPanel Cursor="Hand" ToolTipService.InitialShowDelay="300" ToolTipService.ShowDuration="3000">
            <StackPanel.ToolTip>
                <ToolTip Style="{DynamicResource DiagramToolTip}" Content="{Binding Path=BottomLabel}" />
            </StackPanel.ToolTip>
            <Border Name="DiagramNodeDisplay" Background="{Binding Path=NodeFill}" BorderBrush="{Binding Path=NodeStroke}" BorderThickness="2" CornerRadius="5">
                <Border DataContext="{Binding Path=Item}" >
                    <StackPanel>
                        <Label  Content="{Binding Path=Name}"  FontSize="16" />
                        <ListBox Style="{DynamicResource WorkItemsListBoxStyle}" ItemsSource="{Binding Path=WorkItems}" FontSize="6" />
                    </StackPanel>
                </Border>
            </Border>
        </StackPanel>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{Binding Path=NodeHoverFill}" TargetName="DiagramNodeDisplay" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- Area node AreaNodeTemplate -->
    <ControlTemplate x:Key="AreaNodeTemplate" TargetType="{x:Type local:DiagramNode}">
        <StackPanel Cursor="Hand" ToolTipService.InitialShowDelay="300" ToolTipService.ShowDuration="3000">
            <StackPanel.ToolTip>
                <ToolTip Style="{DynamicResource DiagramToolTip}" Content="{Binding Path=BottomLabel}" />
            </StackPanel.ToolTip>
            <Border Name="DiagramNodeDisplay" Background="{Binding Path=NodeFill}" BorderBrush="{Binding Path=NodeStroke}" BorderThickness="2" CornerRadius="5">
                <Border Name="ItemDisplay" DataContext="{Binding Path=Item}" >
                    <StackPanel>
                        <Label  Content="{Binding Path=Name}"  FontSize="16" />
                        <ListBox ItemsSource="{Binding Path=WorkItems}" FontSize="6" />
                    </StackPanel>
                </Border>
            </Border>
        </StackPanel>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{Binding Path=NodeHoverFill}" TargetName="DiagramNodeDisplay" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- Iteration node IterationNodeTemplate -->
    <ControlTemplate x:Key="IterationNodeTemplate" TargetType="{x:Type local:DiagramNode}">
        <StackPanel Cursor="Hand" ToolTipService.InitialShowDelay="300" ToolTipService.ShowDuration="3000">
            <StackPanel.ToolTip>
                <ToolTip Style="{DynamicResource DiagramToolTip}" Content="{Binding Path=BottomLabel}" />
            </StackPanel.ToolTip>
            <Border Name="DiagramNodeDisplay" Background="{Binding Path=NodeFill}" BorderBrush="{Binding Path=NodeStroke}" BorderThickness="2" CornerRadius="5">
                <Border Name="ItemDisplay" DataContext="{Binding Path=Item}" >
                    <StackPanel>
                        <Label  Content="{Binding Path=Name}"  FontSize="16" />
                        <ListBox ItemsSource="{Binding Path=WorkItems}" FontSize="6" />
                    </StackPanel>
                </Border>
            </Border>
        </StackPanel>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{Binding Path=NodeHoverFill}" TargetName="DiagramNodeDisplay" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- Project primary node ProjectPrimaryNodeTemplate -->
    <ControlTemplate x:Key="ProjectPrimaryNodeTemplate" TargetType="{x:Type local:DiagramNode}">
        <StackPanel ToolTipService.InitialShowDelay="300" ToolTipService.ShowDuration="3000">
            <StackPanel.ToolTip>
                <ToolTip Style="{DynamicResource DiagramToolTip}" Content="{Binding Path=BottomLabel}" />
            </StackPanel.ToolTip>
            <Border Name="DiagramNodeDisplay" Background="{Binding Path=NodeFill}" BorderBrush="{DynamicResource PrimaryStarBrush}" BorderThickness="2" CornerRadius="5">
                <Border Name="ItemDisplay" DataContext="{Binding Path=Item}" >
                    <StackPanel>
                        <Label  Content="{Binding Path=Name}"  FontSize="16" />
                        <ListBox ItemsSource="{Binding Path=WorkItems}" FontSize="6" />
                    </StackPanel>
                </Border>
            </Border>
        </StackPanel>
        <!-- Mouse over -->
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{Binding Path=NodeHoverFill}" TargetName="DiagramNodeDisplay" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- Area primary node AreaPrimaryNodeTemplate -->
    <ControlTemplate x:Key="AreaPrimaryNodeTemplate" TargetType="{x:Type local:DiagramNode}">
        <StackPanel ToolTipService.InitialShowDelay="300" ToolTipService.ShowDuration="3000">
            <StackPanel.ToolTip>
                <ToolTip Style="{DynamicResource DiagramToolTip}" Content="{Binding Path=BottomLabel}" />
            </StackPanel.ToolTip>
            <Border Name="DiagramNodeDisplay" Background="{Binding Path=NodeFill}" BorderBrush="{DynamicResource PrimaryStarBrush}" BorderThickness="2" CornerRadius="5">
                <Border Name="ItemDisplay" DataContext="{Binding Path=Item}" >
                    <StackPanel>
                        <Label  Content="{Binding Path=Name}"  FontSize="16" />
                        <ListBox ItemsSource="{Binding Path=WorkItems}" FontSize="6" />
                    </StackPanel>
                </Border>
            </Border>
        </StackPanel>
        <!-- Mouse over -->
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{Binding Path=NodeHoverFill}" TargetName="DiagramNodeDisplay" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- Iteration primary node IterationPrimaryNodeTemplate -->
    <ControlTemplate x:Key="IterationPrimaryNodeTemplate" TargetType="{x:Type local:DiagramNode}">
        <StackPanel ToolTipService.InitialShowDelay="300" ToolTipService.ShowDuration="3000">
            <StackPanel.ToolTip>
                <ToolTip Style="{DynamicResource DiagramToolTip}" Content="{Binding Path=BottomLabel}" />
            </StackPanel.ToolTip>
            <Border Name="DiagramNodeDisplay" Background="{Binding Path=NodeFill}" BorderBrush="{DynamicResource PrimaryStarBrush}" BorderThickness="2" CornerRadius="5">
                <Border Name="ItemDisplay" DataContext="{Binding Path=Item}" >
                    <StackPanel>
                        <Label  Content="{Binding Path=Name}"  FontSize="16" />
                        <ListBox ItemsSource="{Binding Path=WorkItems}" FontSize="6" />
                    </StackPanel>
                </Border>
            </Border>
        </StackPanel>
        <!-- Mouse over -->
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{Binding Path=NodeHoverFill}" TargetName="DiagramNodeDisplay" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
    
</ResourceDictionary>
